<?php

/**
 * Description of BaseController
 *
 * @author gun
 */
include_once 'AppRegistry.php';
class BaseController extends Zend_Controller_Action {
    
    private $_objDate;
    
    /**
     * This function return date in d-M-Y H:i:s format.
     * 
     * @param datetime $date parameter yg pertama
     * @param string $format parameter yg kedua
     * @return string _objDate
     */
    protected function toViewDate($date) {
        $this->_objDate = new Zend_Date();
        if ($this->_objDate == null) {
            $this->_objDate->set($date);
        }
        
        return $this->_objDate->get('dd-MM-yyyy HH:mm:ss');        
    }
    
    /**
     * This function return date in sql format.
     * 
     * @param datetime $date parameter yg pertama
     * @param string $format parameter yg kedua
     * @return string _objDate 
     */
    protected function toSqlDate($date) {
        $this->_objDate = new Zend_Date();        
        if (!$this->_objDate) {
            $this->_objDate->set($date);
        }
        
        return $this->_objDate->get('yyyy-MM-dd HH:mm:ss');                  
    }
}
